package com.zgjkhis.modules.system.service.impl;

import com.github.pagehelper.PageInfo;
import com.zgjkhis.common.service.impl.BaseServiceImpl;
import com.zgjkhis.domain.PageResult;
import com.zgjkhis.modules.system.domain.Message;
import com.zgjkhis.modules.system.service.MessageService;
import com.zgjkhis.modules.system.service.dto.MessageQueryCriteria;
import com.zgjkhis.modules.system.service.mapper.MessageMapper;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

// 默认不使用缓存
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable;

/**
 * @Author yzq
 * @Description 消息通知
 * @Date 2021/6/23 9:47
 * @Param
 * @return
 **/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class MessageServiceImpl extends BaseServiceImpl<MessageMapper, Message> implements MessageService {

    @Override
    public PageResult<Message> queryAll(MessageQueryCriteria criteria, Pageable pageable) {
        getPage(pageable);
        List<Message> messageList = baseMapper.queryAll(criteria);
        PageInfo<Message> page = new PageInfo<>(messageList);
        return PageResult.data(page);
    }

    @Override
    public List<Message> queryAllNo(MessageQueryCriteria criteria) {
        List<Message> messageList = baseMapper.queryAll(criteria);
        return messageList;
    }

    @Override
    public Integer count(MessageQueryCriteria criteria) {
        return baseMapper.count(criteria);
    }
}
